﻿// LeftFormView.cpp : 实现文件
//

#include "stdafx.h"
//#include "MainFrm.h"
#include "Aries.h"
#include "AriesDoc.h"
#include "LeftFormView.h"
#include "LeftView.h"
#include "RightView.h"


// CLeftFormView

IMPLEMENT_DYNCREATE(CLeftFormView, CFormView)

CLeftFormView::CLeftFormView()
	: CFormView(CLeftFormView::IDD)
{
	m_Brush.CreateSolidBrush(RGB(255,255,255));//设为白色 
}

CLeftFormView::~CLeftFormView()
{
}

void CLeftFormView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO1, m_Code);
	DDX_Control(pDX, IDC_COMBO2, m_Year);
	DDX_Control(pDX, IDC_COMBO3, m_Nyear);
}

BEGIN_MESSAGE_MAP(CLeftFormView, CFormView)
	ON_BN_CLICKED(IDOK, &CLeftFormView::OnBnClickedOk)
	ON_WM_CTLCOLOR()
END_MESSAGE_MAP()


// CLeftFormView 诊断

#ifdef _DEBUG
void CLeftFormView::AssertValid() const
{
	CFormView::AssertValid();
}

#ifndef _WIN32_WCE
void CLeftFormView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif
#endif //_DEBUG


// CLeftFormView 消息处理程序


void CLeftFormView::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
    //CMainFrame* pMainFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);			//获得主框架的指针
	//CRightView *pView = (CRightView *)pMainFrame->m_wndSplitter.GetPane(0,1);	//获得视图类的指针

	CAriesDoc *pDoc=(CAriesDoc *)GetDocument();									//数据传递
	CTreeCtrl &ctlFinanceStatement = pDoc->pLeftView->GetTreeCtrl();	
	HTREEITEM nodSelected = ctlFinanceStatement.GetSelectedItem();	            //判断选中节点内容
	CString strSelected = ctlFinanceStatement.GetItemText(nodSelected);
	m_Code.GetWindowTextW(pDoc->m_Code);		   						       
	m_Year.GetWindowTextW(pDoc->m_Year);
	m_Nyear.GetWindowTextW(pDoc->m_Nyear);
	pDoc->m_Fcf.clear();   //清空FCF数据容器
	pDoc->GetDbData();
	pDoc->pLeftView->SelectDisplayType(strSelected);		
	if(theApp.m_pConn==NULL)
	{
		AfxMessageBox(_T("请先登录数据库！！！"));
	}

}


HBRUSH CLeftFormView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO:  在此更改 DC 的任何特性
	 if(nCtlColor==CTLCOLOR_DLG || nCtlColor==CTLCOLOR_STATIC)  
	 {	 pDC->SetBkMode(TRANSPARENT);
		 return   (HBRUSH)m_Brush.GetSafeHandle();   
	 }
	// TODO:  如果默认的不是所需画笔，则返回另一个画笔
	return hbr;
}
